import { mountComponent } from "@/uitls/utils";
import { Teleport, h, createApp, DefineComponent, App } from "vue"
import dialog from "./dialogComponent.vue"

export class Dialog {
    static options: {
        title?: string,
        size?: string,
        component?: DefineComponent,
        show?: () => boolean
    };

    static vueHtml: App<Element>
    static unmount: () => void

    static getDialog = (options: object) => {
        this.options = options
        const showDialog = (context: typeof Dialog, params: object | undefined) => {
            const { instance, unmount } = mountComponent(dialog)
            this.unmount = unmount
        }
        return {
            title: (_title: string) => { this.options.title = _title; return this },
            size: (_size: string) => { this.options.size = _size; return this },
            show: (_params?: object) => showDialog(this, _params),
            compontent: (_component: DefineComponent) => { this.options.component = _component; return this }
        }
    }

    static close = () => {

    }
}